package com.example.ioc;

import com.example.ioc.controller.HelloController;
import com.example.ioc.controller.UserController;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ApplicationContext;


@SpringBootApplication
public class SpringIocApplication {

    public static void main(String[] args) {

        ApplicationContext context = SpringApplication.run(SpringIocApplication.class, args);
//        HelloController bean1 = context.getBean(HelloController.class);
//        bean1.sayHi();
//        System.out.println(bean1);
//
//        HelloController bean2 = (HelloController) context.getBean("helloController");
//        bean2.sayHi();
//        System.out.println(bean2);
//
//        HelloController bean3 = (HelloController) context.getBean("helloController", HelloController.class);
//        bean3.sayHi();
//        System.out.println(bean3);



//        UController bean1 = context.getBean(UController.class);
//        bean1.sayHi();
//        System.out.println(bean1);

//        UController bean2 = (UController) context.getBean("UController");
//        bean2.sayHi();
//        System.out.println(bean2);

//        UController bean3 = (UController) context.getBean("UController", UController.class);
//        bean3.sayHi();
//        System.out.println(bean3);

            //bean-类   命名规则  用类名
//        System.out.println(Introspector.decapitalize("HelloController"));
//        System.out.println(Introspector.decapitalize("UController"));


//        UserComponent bean = context.getBean(UserComponent.class);
//        bean.doComponent();
//        UserService bean1 = context.getBean(UserService.class);
//        bean1.doService();
//        UserConfig bean2 = context.getBean(UserConfig.class);;
//        bean2.doConfig();
//        UserRepo bean3 = context.getBean(UserRepo.class);
//        bean3.doRepo();


//        UserInfo bean = context.getBean(UserInfo.class);
//        System.out.println(bean);

//        UserInfo bean = (UserInfo) context.getBean("user");
//        System.out.println(bean);


//        HelloController bean = context.getBean(HelloController.class);
//        bean.sayHi();


        UserController bean = context.getBean(UserController.class);
        bean.sayHi();


    }

}
